<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of indexAction
 *
 * @author wuxiaofeng
 */
class IndexAction extends MenuAction{
    //put your code here
    function index(){
        $Content = M('Content');
        $Category=M('Category');
        $ContentThumb = M('ContentThumb');
        
        $Contentself=$Content->where('content_title!=""')->order('content_id asc')->limit(5)->select();    
        $Hotcontent=$Content->where('content_title!=""')->order('content_click_count desc')->find();
        $Hotcontent5=$Content->where('content_title!=""')->order('content_click_count desc')->limit(5)->select();
        $Contentwithattach=$Content->where('content_attach')->order('content_click_count desc')->limit(5)->select();
        
        $thumb =$ContentThumb->order('thumb_id desc')->limit('5')->select();
        $thumbeach =$ContentThumb->order('thumb_id asc')->select();
        $fivethumb =$ContentThumb->order('thumb_id desc')->limit('5')->select();
        
        
        $mainnavi1 = $Category->where('category_state=1')->order('category_sort asc')->select();
        
        //输出各分类的content
        
        $mainnavi1 = $Category->where('category_state=1')->order('category_sort ASC')->select();
        $infosa1=array();
        foreach($mainnavi1 as $key => $acategory){
            $infoa1=$Content->where('category_id='.$acategory['category_id'].' AND content_state=1')->order('content_time desc')
                    ->limit(6)->select();
            $infosa1[]=$infoa1;
        }
        
      //
                
                
        //输出缩略图
        foreach ($thumb as $value) {
			$image = $Content->where('content_id='.$value['thumb_content'] .' AND content_state=1')->find();
                       
			$thumbone[] = $image['content_title'];
			$thumbone[] = $value;
			$thumbs[] = $thumbone;
			unset($thumbone);
		}   
                
                
        foreach($thumbeach as $value){
            $images=$Content->where('content_id='.$value['thumb_content'].' AND content_state=1')->find();
            $thumbtwo[]=$images['content_title'];
            $thumbtwo[]=$value;
            $thumbtwo[]=$images['category_id'];
            $thumbs1[]=$thumbtwo;
            unset($thumbtwo);
        }
        
        foreach($thumbs1 as $value){
            if($value[2]=='014'){
                $thumbfor14=$value;
            }
            elseif ($value[2]=='015') {
               $thumbfor15=$value;
        }
           elseif ($value[2]=='016') {
               $thumbfor16=$value;
        }
          elseif ($value[2]=='017') {
               $thumbfor17=$value;
        }
          elseif ($value[2]=='018') {
               $thumbfor18=$value;
        }
          elseif ($value[2]=='019') {
               $thumbfor19=$value;
        }
          elseif ($value[2]=='020') {
               $thumbfor20=$value;
        }
         
          $thumblast[]=$value;
     }
        
        
        
                
        $infosa10=$infosa1[0];   
        //var_dump($infosa10);
          //      exit;
        $infosa11=$infosa1[1]; 
        $infosa12=$infosa1[2]; 
        $infosa13=$infosa1[3]; 
        $infosa14=$infosa1[4]; 
        $infosa15=$infosa1[5]; 
        $infosa16=$infosa1[6]; 
        
        $this->assign('hotcontent',$Hotcontent);
        $this->assign('hotcontent5',$Hotcontent5);
        $this->assign('infosa1',$infosa1);
        $this->assign('infosa10',$infosa10);   
        $this->assign('infosa11',$infosa11); 
        $this->assign('infosa12',$infosa12);
        $this->assign('infosa13',$infosa13); 
        $this->assign('infosa14',$infosa14); 
        $this->assign('infosa15',$infosa15); 
        $this->assign('infosa16',$infosa16); 
        
        $this->assign('contentwithattach',$Contentwithattach);
        
        $this->assign('fivethumb',$fivethumb);
        $this->assign('thumbs',$thumbs);   
        
        $this->assign('thumbfor14',$thumbfor14);
        $this->assign('thumbfor15',$thumbfor15);
        $this->assign('thumbfor16',$thumbfor16);
        $this->assign('thumbfor17',$thumbfor17);
        $this->assign('thumbfor18',$thumbfor18);
        $this->assign('thumbfor19',$thumbfor19);
        $this->assign('thumbfor20',$thumbfor20);
        $this->assign('thumbfor21',$thumbfor21);
        $this->assign('thumbfor22',$thumbfor22);
        $this->assign('thumbfor23',$thumbfor23);
        
        $this->assign('contentself',$Contentself);
        $this->display();
        
    }
}

?>
